package com.cai.servlet.common.user.log;

import com.cai.dao.MessageDao;
import com.cai.dao.impl.MessageDaoImpl;
import com.cai.pojo.TopicHelp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author RuoLi
 * 添加消息
 */
@WebServlet(name = "ServletInsertMessage", value = "/common/log/InsertMessage")
public class ServletInsertMessage extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        MessageDao messageDao = new MessageDaoImpl();
        TopicHelp help = new TopicHelp();
        help.setTip_title(req.getParameter("tipTitle"));
        help.setTip_context(req.getParameter("tipContext"));
        int status = messageDao.insertMessage(help);
        resp.getWriter().write(String.valueOf(status));
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
